{include file="header" title="官方安装程序" keywords="" description=""/}
<div class="step-bar">
    <div class="am-container">
        <div class="am-g setp-title">
            <div class="am-u-sm-6 am-text-right">
                <h1>Step.4</h1>
            </div>
            <div class="am-u-sm-6 am-text-left">
                <h3>开始安装</h3>
                <p>检测服务器环境及文件目录权限</p>
            </div>
        </div>
        <div class="am-g step">
            <div class="am-u-sm-3 am-active">
                <i class="am-icon am-icon-search"></i>
                <div class="line"></div>
                <spa>检查安装环境</spa>
            </div>
            <div class="am-u-sm-3 am-active">
                <i class="am-icon am-icon-cogs"></i>
                <div class="line"></div>
                <span>选择安装方式</span>
            </div>
            <div class="am-u-sm-3 am-active">
                <i class="am-icon am-icon-database"></i>
                <div class="line"></div>
                <span>创建数据库</span>
            </div>
            <div class="am-u-sm-3 am-active">
                <i class="am-icon am-icon-bullseye"></i>
                <div class="line"></div>
                <span>安装</span>
            </div>
        </div>
    </div>
</div>
<div class="install-load">
    <div class="am-container">
        <div class="loading">
            <i class="am-icon-spinner am-icon-spin"></i>
            <span>正在安装中...</span>
        </div>
    </div>
</div>

{include file="footer" /}
<div class="am-modal am-modal-no-btn" tabindex="-1" id="alert-modal">
    <div class="am-modal-dialog">
        <div class="am-modal-bd"></div>
    </div>
</div>
<script>
    $(function () {
        $.ajax({
            url: "<?= url('/install/step4/setup');?>",
            data: {
                '__token__': '{$Request.token}'
            },
            type: 'post',
            cache: false,
            dataType: 'json',
            success: function (res) {
                //console.log(res);
                //return false;
                if (res['code'] == 1) {
                    redirect("<?= url('/install/complete/index')?>");
                } else {
                    $('#alert-modal').find('.am-modal-bd').html(res.message);
                    $('#alert-modal').modal('open').delay(3000).show(function () {
                        $('#alert-modal').modal('close');
                    });
                    setTimeout("redirect('<?= url('/install/step3')?>')", 3000);
                }
            },
            error: function () {
                $('#alert-modal').find('.am-modal-bd').html('操作异常');
                $('#alert-modal').modal('open').delay(3000).show(function () {
                    $('#alert-modal').modal('close');
                });
                setTimeout("redirect('<?= url('/install/step3')?>')", 3000);
            }
        });
    });
    function redirect(url) {
        window.location.href = url;
    }
</script>
